﻿using System;
using Sinacor.Servico.Bovespa.Ordens.Service.DataContract.Request;
using Sinacor.Servico.Bovespa.Ordens.BusinessEntity;
using System.Collections.Generic;
using System.ComponentModel;

namespace Sinacor.Servico.Bovespa.Ordens.Service.ServiceImplementation.Translator
{
    public static class TranslateConsultarOrdemDistribuicao
    {
        /// <summary>
        /// Autor: LLiez.7comm
        /// </summary>
        /// <param name="from"></param>
        /// <returns></returns>
        public static BusinessEntity.Parameter.ConsultarOrdemDistribuicao ToBusinessEntity(ConsultarOrdemDistribuicaoRequest from)
        {
            if (from == null)
                return null;  

            BusinessEntity.Parameter.ConsultarOrdemDistribuicao to = new BusinessEntity.Parameter.ConsultarOrdemDistribuicao();
            to.ApelidoCliente = from.ApelidoCliente;
            to.DataPregao = from.DataPregao;
            to.Titulo = from.Titulo;
            to.OrdemDistribuicaoGrupo = (BusinessEntity.Enum.OrdemDistribuicaoGrupo)new System.ComponentModel.EnumConverter(from.OrdemDistribuicaoGrupo.GetType()).ConvertFrom(from.OrdemDistribuicaoGrupo.ToString());             
            to.Discricionaria = from.Discricionaria;            

            return to;
        }

        /// <summary>
        /// Autor: LLiez.7comm
        /// </summary>
        /// <param name="list"></param>
        /// <returns></returns>
        public static List<DataContract.Response.OrdemResponse> ToResponse(List<BusinessEntity.Ordem> list) 
        {
            return TranslateOrdem.ToOrdemResponseList(list);
        }
    }
}
